<!DOCTYPE html>
<html>
<head>
<title>Template</title>
<link rel="stylesheet" type="text/css" href="css/WeVal_Master_CSS.css">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script language="javascript" type="text/javascript" src="javascripts/teacher-dashboard.js"></script>
	<script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
	
<script type="text/javascript">
	function getPixelLength()
	{
		var result = [];
		result.push(getAnswerLength(window.currentSD));
		result.push(getAnswerLength(window.currentD));
		result.push(getAnswerLength(window.currentN));
		result.push(getAnswerLength(window.currentA));
		result.push(getAnswerLength(window.currentSA));
		
		return result;		
	}
	function getAnswerLength(answerCount)
	{
		if(answerCount == 0 || window.currentTotal == 0)
		{
			return 0;
		}
		var returnValue = ((answerCount/window.currentTotal) * window.totalBarLength);
		return returnValue;
	}
	function appendQuestion()
	{
		<!-- $("#array").append('<div style=" background-color:#e8464a;width:'+window.currentLengths[0]+'px;">&nbsp;</div>'); -->
		<!-- $("#array").append('<div style=" background-color:#f4a8aa;width:'+window.currentLengths[1]+'px;">&nbsp;</div>'); -->
		<!-- $("#array").append('<div style=" background-color:#f0ecd5;width:'+window.currentLengths[2]+'px;">&nbsp;</div>'); -->
		<!-- $("#array").append('<div style=" background-color:#a2d2d7;width:'+window.currentLengths[3]+'px;">&nbsp;</div>'); -->
		<!-- $("#array").append('<div style=" background-color:#7092be;width:'+window.currentLengths[4]+'px;">&nbsp;</div>'); -->
		<!-- window.currentQuestion, window.currentSD, window.currentD, window.currentN, window.currentA, window.currentSA; -->
		$("#questions_wrapper").append('<div class="question_box"><div class="expander plusMinus">+</div><div class="question">'+window.currentQuestion+'</div><div class="question_graph"><div class="graphBox graphStronglyDisagree"  style=" width:'+window.currentLengths[0]+'px;">&nbsp;</div><div class="graphBox graphDisagree"  style=" width:'+window.currentLengths[1]+'px;">&nbsp;</div><div class="graphBox graphNeutral"  style=" width:'+window.currentLengths[2]+'px;">&nbsp;</div><div class="graphBox graphAgree"  style=" width:'+window.currentLengths[3]+'px;">&nbsp;</div><div class="graphBox graphStronglyAgree"  style=" width:'+window.currentLengths[4]+'px;">&nbsp;</div></div><div class="question_scores"><div class="question_answers">SD: '+window.currentSD+'</div><div class="question_answers">D: '+window.currentD+'</div><div class="question_answers">N: '+window.currentN+'</div><div class="question_answers">A: '+window.currentA+'</div><div class="question_answers">SA: '+window.currentSA+'</div></div></div><p></p>');		
	}
	var totalBarLength = 400;
	var currentQuestion = " ";
	var currentSD = 0;
	var currentD = 0;
	var currentN = 0;
	var currentA = 0;
	var currentSA = 0;
	var currentTotal = 0;
	var currentLengths = [ ];
	var finishedQuestions = [ ];
	var printedQuestions = [ ];
	
	window.onload=(function() {

		jQuery.get('https://chitester1dev.weber.edu:6838/misc/weber/CSEvals/AnswerCount.cfm?crn=30594&semester=3&year=2013', function(data) {

			$.each(data.DATA, function(i,array) {
				<!-- $("#array2").append( array[0] + " - " + array[1] + " - " + array[2]  + " - "  + array[3]  + " - " + array[4] + "<br>" ); -->

					window.currentQuestion = array[2];
					$.each(data.DATA, function(i,innerArray){
						if(window.currentQuestion == innerArray[2] && window.finishedQuestions.indexOf(window.currentQuestion + " - " + innerArray[3]) == -1)
						{
							switch(innerArray[3])
							{
								case 'strongly disagree' :
								case 'very poor' :
									window.currentSD+= +innerArray[4];
									window.currentTotal+= +innerArray[4];
									break;
								case 'disagree' :
								case 'poor' :
									window.currentD+= +innerArray[4];
									window.currentTotal+= +innerArray[4];					
									break;
								case 'neutral' :
								case 'average' :
									window.currentN+= +innerArray[4];
									window.currentTotal+= +innerArray[4];
									break;
								case 'agree' :
								case 'good' :
									window.currentA+= +innerArray[4];
									window.currentTotal+= +innerArray[4];
									break;					
								case 'strongly agree' :
								case 'excellent' :
									window.currentSA+= +innerArray[4];
									window.currentTotal+= +innerArray[4];
									break;
							}
							
							window.finishedQuestions.push(window.currentQuestion + " - " + innerArray[3]);
		
						}
					});
					
					if(window.printedQuestions.indexOf(window.currentQuestion) == -1)
					{
						window.currentLengths = getPixelLength();
						window.printedQuestions.push(window.currentQuestion);
						$("#array").append('<p style="clear:both;">' + window.currentQuestion + " - " + window.currentSD + " - " + window.currentD + " - "  + window.currentN + " - " + window.currentA +" - " + window.currentSA +" - " + window.currentTotal + "</p><br>" );
						
						appendQuestion();

					}
					window.currentQuestion = " ";
					window.currentSD = 0;
					window.currentD = 0;
					window.currentN = 0;
					window.currentA = 0;
					window.currentSA = 0;
					window.currentTotal = 0;
						
			});
		});
	});


	
</script>
</head>
<body class="body" >
 <div class="wrapper">

 	<div class="header">
 		<a href="teacher-dashboard.html"><img src="images/weval-logo-resize.png" alt="Logo"/></a>	
		<div class=filter>
			<form name="input" action="" method="">
				Overall Course Evaluations for:		
				<select>
					<option value="teacherName">Brad Peterson</option>
				</select>			
				<select>
					<option value="semester1">Summer 2013</option>
					<option value="semester2">Spring 2013</option>
					<option value="semester3">Fall 2012</option>
				</select>			
				<input type="submit" value="Submit">
			</form>	
		</div>
 	</div>
	<div class="summary_box">
		<div class="summary_main">
			<div class="expander plusMinus">+</div>
			<div class="summary_text">
				CS1400-67877 Spr 13 Overall Score</br>
				Department Average Spr 13
			</div>
			<div class="summary_graph">
				graph
			</div>
			<div class="summary_detail">
			
			</div>
		</div>
	</div>

    <div class="bar"><hr></div>
	
	<div class="legend_box">
		<div class="legend">
				LEGEND
		</div>
		<div class="legend_graph">
			
				<div class="graphBox graphStronglyDisagree">Strongly Disagree</div>	
				<div class="graphBox graphDisagree">Disagree</div>
				<div class="graphBox graphNeutral">Neutral</div>
				<div class="graphBox graphAgree">Agree</div>
				<div class="graphBox graphStronglyAgree">Strongly<br/> Agree</div>	
								
		</div>
	</div>
	<div id="questions_wrapper">
		
	</div>	
	
    <div class="footer">
    	&copy 2013 Weber State University
   		
    </div>
 </div>

</body>
</html>